SUBROUTINE MAKETABLE4
     * Create a simple table and populate it with data from
     * a Reality file. Draw borders round the cells.
     * Right align the columns.

     * Include the RealWeb definitions.
     INCLUDE #RW.INCLUDE.DEFS FROM /SYSFILES/REALWEB,BP

     EQU AM TO CHAR(254)
     EQU VM TO CHAR(253)
     EQU TAB TO CHAR(9)

     * Get the URL of the Reality item server.
     STYLESHEET = ""
     CALL RW_GET_PARAM("__isurl", STYLESHEET)
     * Specify the location of the stylesheet.
     STYLESHEET = STYLESHEET : "/REALWEB-ITEMS/blue.css"

     * Start the HTML page.
     CALL RW_START_HTML_PAGE("RW_MAKE_TABLE Example 4", "", STYLESHEET, "", "")

     TEXT = "Hotel Guests"
     CALL RWS_HEADING(TEXT, 2, "")
     CALL RW_PUT(TEXT)

     * Assemble some data to go in the table.
     *   Get some data to insert.
     PERFORM "SORT-SPREAD GUESTS < '200' " : ...
        "ROOM NAME ADDRESS CITY STATE ZIP ID-SUPP" ...
        CAPTURING aData
     *   The headings are in the second attribute.
     DEL aData<1>
     aHeadings = aData<1>
     *   SORT-SPREAD returns tab-separated data; we need a dynamic array.
     aHeadings = CHANGE(aHeadings, TAB, AM)
     *   The data is in the third attribute onwards.
     DEL aData<1>
     *   SORT-SPREAD returns tab-separated data; we need a dynamic array.
     aData = CHANGE(aData, TAB, VM)

     * Right align all the columns.
     aDataFormat = ""
     FOR I = 1 TO DCOUNT(aHeadings, AM)
        aDataFormat<I> = VM : "RIGHT"
     NEXT I

     aClass = ""
     aClass<2> = "border"                        ;* Give the table a border.
     aClass<3> = "bgcolor=lightsteelblue"        ;* Set a background colour.
     aClass<4> = "cellspacing=0 cellpadding=5"   ;* Add some space around the text.

     * Create the table.
     CALL RW_MAKE_TABLE(aHeadings, aData, aDataFormat, aClass, RWD_IGNORE_EMPTY_ROWS)

     * Complete the page.
     CALL RW_END_PAGE
RETURN

Go to top button